home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8992 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: newshost.cyberramp.net!news
  2. From: sinan@cyberramp.net (John Noland)
  3. Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.pl1
  4. Subject: Re: GOTO controversy
  5. Date: 7 Mar 1996 21:23:02 GMT
  6. Organization: Prose Software
  7. Message-ID: <4hnk3m$jbb@newshost.cyberramp.net>
  8. References: <rcshlds.1.000A6705@mailserv.mta.ca> <Dn8pJ8.nqs@emi.net> <4grt4e$8fg@goanna.cs.rmit.EDU.AU> <4hl8mt$4po@newshost.cyberramp.net> <wallaceDnvoEo.7L7@netcom.com>
  9. NNTP-Posting-Host: ramp2-13.cyberramp.net
  10. X-Newsreader: WinVN 0.99.5
  11.  
  12. In article <wallaceDnvoEo.7L7@netcom.com>, wallace@netcom.com says...
  13. >
  14. >Ok, I'll bite: why is a subroutine with multiple gotos to a single exit point
  15. >a "lot" easier to maintain than that same routine with multiple returns?
  16. >
  17. >The only maintenance tasks that I can see that get any easier are inserting 
  18. >special-purpose cleanup code that must run before a given function returns 
  19. >(regardless of why it is returning)
  20.  
  21. This was what I had in mind when I wrote that. I probably should have provided
  22. an example and said that in THIS particular situation a goto to a single exit
  23. point is much preferable to multiple return statements. 
  24.  
  25. I did a grep on all of my C source files for the accounting system I work 
  26. on and found only 3 goto's in 250,000+ lines of code. So, if you were to take 
  27. these guidelines as hard and fast rules as to when to USE goto, well, then, I 
  28. obviously don't follow them very well myself.
  29.  
  30. Sorry all, in retrospect I didn't do very well in presenting my views. Please
  31. forgive me!
  32.  
  33. -John
  34.  
  35.